<template>
    <el-dialog v-model="showCenterDialog" :title="!props.content?'文件预览(内容不全请下载查看)':props.title" width="500">
        <span v-if="props.content">{{ props.content }}</span>
        <slot name="content"></slot>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="showCenterDialog = false">取消</el-button>
                <el-button type="primary" @click="handleConfirm">
                    确定
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue';
const props = withDefaults(
    defineProps<{
        confirmFunction?: Function,
        title?: string,
        content?: string
    }>(),
    {
        confirmFunction: () => { },
        title: '温馨提示',
        content: '默认内容'
    }
);

const showCenterDialog = ref(false);
const handleConfirm = () => {
    if (props.confirmFunction) {
        props.confirmFunction();
    }
    showCenterDialog.value = false;
}
defineExpose({ showCenterDialog });
</script>
